package com.wlyuan.open.scanner.application.handler.full;

import com.wlyuan.open.dto.OpenGoodsSyncDTO;
import com.wlyuan.open.scanner.application.annotation.ScannerCode;
import com.wlyuan.open.scanner.assembler.ScannerGoodsAssembler;
import com.wlyuan.open.scanner.constant.ScannerCodeEnum;
import com.wlyuan.open.scanner.domain.goods.Goods;
import com.wlyuan.open.scanner.repository.GoodsRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lijing
 * @description
 */
@ScannerCode(code = ScannerCodeEnum.GOODS)
@Service
@Slf4j
@RequiredArgsConstructor
public class ScannerGoodsHandler extends BaseScannerHandler<Goods, OpenGoodsSyncDTO> {

    private final GoodsRepository goodsRepository;

    @Override
    protected List<Goods> select() {
        return goodsRepository.list();
    }

    @Override
    protected List<OpenGoodsSyncDTO> assembler(List<Goods> data) {
        return ScannerGoodsAssembler.assemble(data);
    }

}
